package com.ruoyi.chat.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.chat.mapper.ChatRecordMapper;
import com.ruoyi.chat.domain.ChatRecord;
import com.ruoyi.chat.service.IChatRecordService;

/**
 * 消息记录Service业务层处理
 *
 * @author ch
 * @date 2021-11-19
 */
@Service
public class ChatRecordServiceImpl implements IChatRecordService
{
    @Autowired
    private ChatRecordMapper chatRecordMapper;

    /**
     * 查询消息记录
     *
     * @param id 消息记录主键
     * @return 消息记录
     */
    @Override
    public ChatRecord selectChatRecordById(Long id)
    {
        return chatRecordMapper.selectChatRecordById(id);
    }

    /**
     * 查询消息记录列表
     *
     * @param chatRecord 消息记录
     * @return 消息记录
     */
    @Override
    public List<ChatRecord> selectChatRecordList(ChatRecord chatRecord)
    {
        return chatRecordMapper.selectChatRecordList(chatRecord);
    }

    /**
     * 新增消息记录
     *
     * @param chatRecord 消息记录
     * @return 结果
     */
    @Override
    public int insertChatRecord(ChatRecord chatRecord)
    {
        chatRecord.setCreateTime(DateUtils.getNowDate());
        return chatRecordMapper.insertChatRecord(chatRecord);
    }

    /**
     * 修改消息记录
     *
     * @param chatRecord 消息记录
     * @return 结果
     */
    @Override
    public int updateChatRecord(ChatRecord chatRecord)
    {
        chatRecord.setUpdateTime(DateUtils.getNowDate());
        return chatRecordMapper.updateChatRecord(chatRecord);
    }

    /**
     * 批量删除消息记录
     *
     * @param ids 需要删除的消息记录主键
     * @return 结果
     */
    @Override
    public int deleteChatRecordByIds(Long[] ids)
    {
        return chatRecordMapper.deleteChatRecordByIds(ids);
    }


    /**
     * 批量逻辑删除消息记录
     *
     * @param ids 需要删除的消息记录主键
     * @return 结果
     */
    @Override
    public int logicDeleteChatRecord(Long[] ids,String delType,Long delUser)
    {
        return chatRecordMapper.logicDeleteChatRecord(ids,delType,delUser);
    }

    /**
     * 删除消息记录信息
     *
     * @param id 消息记录主键
     * @return 结果
     */
    @Override
    public int deleteChatRecordById(Long id)
    {
        return chatRecordMapper.deleteChatRecordById(id);
    }
    @Override
    public int updateReadStatus(long storeId,long memberId,String tostoreState)
    {
        return chatRecordMapper.updateReadStatus( storeId, memberId, tostoreState);
    }
}
